package com.aliyun.messagemgt.common.dto.send;

import com.aliyun.messagemgt.common.annotation.CustomAnnotation;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IDEA
 *
 * @author:zhangxingxing 0027012120
 * @date:2019/1/22
 * @time:17:42
 */
@Data
@Accessors(chain = true)
@JsonInclude(value = JsonInclude.Include.NON_NULL)
public class MsgRecordVO {

    /**
     * 消息记录id
     */
    @JsonIgnore
    private Long msgId;
    /**
     * 消息唯一标识(消息发送方提供,以便解析这个消息)
     */
    @CustomAnnotation(name = "uniqueId", desc = "消息唯一标识")
    private String uniqueId;
    /**
     * 标题
     */
    @NotNull(message = "消息标题 msgTitle 不能为空")
    @CustomAnnotation(name = "msgTitle", desc = "标题")
    private String msgTitle;
    /**
     * 描述
     */
    @NotNull(message = "消息描述 msgDescription 不能为空")
    @CustomAnnotation(name = "msgDescription", desc = "消息描述")
    private String msgDescription;
    /**
     * 消息类型
     */
    @JsonIgnore
    @CustomAnnotation(name = "messageType", desc = "消息类型")
    private String messageType;

    /**
     * mPaaS 目标ID类型 1-Android 2-iOS 3-用户维度
     */
    private Integer deliveryType;

    /**
     * 邮件渠道：主题
     */
    private String subject;

    /**
     * 邮件渠道：附件地址 （可以直接访问到附件）
     */
    private String attachmentAddress;

    /**
     * 计划ID
     */
    @Deprecated
    private Integer planId;
    /**
     * 计划名
     */
    @Deprecated
    private String planName;
    /**
     * 场景ID
     * 2020年4月13日 该字段对接mpaas,用于选择推送方式1-简单推送 2-模板推送 3-批量推送 4-群发推送
     */
    @Deprecated
    private Integer sceneTemplateId;

    /**
     * 模板id
     */
    private Long templateId;

    /**
     * 模板名称
     */
    private String templateName;
    /**
     * 推送渠道Id
     */
    @JsonIgnore
    private String pushChannelId;

    /**
     * 推送渠道编码
     */
    private String pushChannelCode;
    /**
     * 推送渠道名称
     */
    @JsonIgnore
    private String pushChannelName;
    /**
     * 推送渠道类型
     */
    private String pushChannelType;

    /**
     * 所属部门
     */
    @JsonIgnore
    private String ownerDept;
    /**
     * 所属部门名称
     */
    @JsonIgnore
    private String ownerDeptName;
    /**
     * 评论类型
     */
    @JsonIgnore
    private Integer commentType;
    /**
     * 内容
     */
    @Valid
    @NotNull(message = "消息体内容 contents 不能为空")
    private List<MsgBody> contents;

    /**
     * 推送标签id
     */
    @Deprecated
    private Integer pushLabelId;
    /**
     * 消息源id
     */
    @JsonIgnore
    private Long msgSourceId;

    /**
     * 消息源名称
     */
    @JsonIgnore
    private String msgSourceName;
    /**
     * 消息源类型 1 智能推送 2 监控报警 3 API
     */
    @JsonIgnore
    private Integer msgSourceType;
    /**
     * 创建用户
     */
    private String userCreate;
    /**
     * 最终接收者
     */
    @JsonIgnore
    private List<Receiver> receivers;

    /**
     * 推送结果
     */
    private List<MsgMiddleResult> results = new ArrayList<>();
    /**
     * 重发推送结果
     */
    @Deprecated
    private List<MsgMiddleResult> resendResults;

    /**
     * 按钮排序  0-按钮竖直排列，1-按钮横向排列
     */
    @Deprecated
    private String btnOrientation;

    /**
     * 内容体
     */
    @Deprecated
    private String msgContent;

    /**
     * 租户编码
     */
    @NotBlank(message = "tenantCode 不为空")
    @CustomAnnotation(name = "tenantCode", desc = "租户编码")
    private String tenantCode;

    @CustomAnnotation(name = "status", desc = "消息执行状态")
    @JsonIgnore
    private Boolean status = true;

    /**
     * 业务场景编码
     */
    @NotBlank(message = "sceneCode 不为空")
    @CustomAnnotation(name = "sceneCode", desc = "业务场景编码")
    private String sceneCode;

    /**
     * 业务场景名称
     */
    @CustomAnnotation(name = "sceneName", desc = "业务场景名称")
    private String sceneName;

    @CustomAnnotation(name = "receiveChannelCodes", desc = "接收渠道编码清单")
    private List<String> receiveChannelCodes;

    /**
     * 失败重发次数
     */
    @CustomAnnotation(name = "failureResendTimes", desc = "失败重发次数")
    private int failureResendTimes;
    /**
     * 失败重发时间间隔
     * 单位：分钟
     */
    @CustomAnnotation(name = "failureResendInterval", desc = "失败重发时间间隔")
    private int failureResendInterval;

    @NotNull(message = "receiveRangeInfo 不为空")
    @CustomAnnotation(name = "receiveRangeInfo", desc = "接收范围信息")
    @Valid
    @ApiModelProperty("接收范围信息")
    private MsgPushDTO.MsgRecordDTO.ReceiveRangeInfo receiveRangeInfo;

    //========================================TODO 消息发送预置属性=============================================
    /**
     * 渠道信息
     */
    @ApiModelProperty(hidden = true)
    List<PushChannelInfo> pushChannelInfoList;

    /**
     * ","分割的dingTalkUserId(暂为钉钉工作通知使用)
     */
    private String dingTalkUserIdList;

    @ApiModelProperty("消息源编码")
    private String msgSourceCode;
}
